

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置我的密码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid" id="set-password-form">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header">修改密码</div>
        <div class="layui-card-body" pad15>

          <div class="layui-form" lay-filter="">
            <div class="layui-form-item">
              <div class="layui-input-inline">
                <input type="hidden" name="expertId" lay-verify="required" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">姓名</label>
              <div class="layui-input-inline">
                <input type="text" name="expertName" lay-verify="required" lay-verType="tips" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">手机号</label>
              <div class="layui-input-inline">
                <input type="text" name="expertPhone" lay-verify="required" lay-verType="tips" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">性别</label>
              <div class="layui-input-inline">
                <input type="radio" name="expertSex" value="0" title="男">
                <input type="radio" name="expertSex" value="1" title="女">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">邮箱</label>
              <div class="layui-input-inline">
                <input type="text" name="expertEmail" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">登录账号</label>
              <div class="layui-input-inline">
                <input type="text" name="expertUsername" lay-verify="required" readonly lay-verType="tips" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">(登录账号不可修改)</div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="set_info" id="set_info">确认修改</button>
              </div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>
</div>

<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'],function () {
        var $ = layui.$
            ,form = layui.form;
      //回显数据
        $.get("/admin/expert/expert",function (obj) {
            $("[name=expertId]").val(obj.expertId);
            $("[name=expertName]").val(obj.expertName);
            $("[name=expertPhone]").val(obj.expertPhone);
            $("[name=expertEmail]").val(obj.expertEmail);
            $("[name=expertUsername]").val(obj.expertUsername);
            $("[name=expertSex]").each(function () {
                if (obj.expertSex == $(this).val()) {
                    $(this).attr("checked", true);
                }
            });
            form.render();
        });


        //监听提交
        form.on('submit(set_info)', function(data){
            var field = data.field; //获取提交的字段
            console.log(field);
            $.ajax({
                url:"/admin/expert/expert",
                method:"put",
                data:field,
                dataType:"json",
                async:false,
                success:function(obj){
                    if(obj.code == 0){
                        layer.msg('修改成功',{
                            offset: '15px'
                            ,icon: 1
                            ,time:1000
                        });
                    }else{
                        layer.msg(obj.msg);
                    }
                }
            });
        });
    });
</script>
</body>
</html>